package com.yang.factory;

import java.util.HashMap;
import java.util.Map;

/**
 * 直接调用某个个类的静态方法就可以返回一个bean的实例
 * */
public class StaticCarFactory {

    private static Map<String,Car> cars = new HashMap<String, Car>();
    static {
        cars.put("audi",new Car("宝马",30000));
        cars.put("ford",new Car("福特",40000));
    }

    //静态工厂方法
    public static Car getCar(String name){
        return cars.get(name);
    }
}
